{include file="start" /}
{include file="header" /}
<title>重卡汇</title>
<link rel="stylesheet" href="/_hongyanche/css/app.css">

<style>
.week-wrap{position: fixed; width: 100%; height: 100%;}
.week-wrap .header{text-align: center;font-size: 1.3rem;color: white;font-weight: 800;background: cadetblue;}
.week-wrap .week-detail{margin-top: 0;}
.week-detail .week-title{ font-size: 16px; font-weight: 600; display: flex;}
.week-detail .week-title div{flex: 1;}
.week-detail .item{display: flex;}
.week-detail .item div{font-size: 14px; flex: 1;}
</style>

<body>
    <div class="week-wrap">
        <div class="header">
            <span style="float:left;" id="back"><</span>
            报表
        </div>
        <div class="week-detail weui-cells">
            <div class="weui-cell week-title">
                <div class=" weui-cell__hd">日期</div>
                <div class=" weui-cell__hd">当天油耗</div>
                <div class=" weui-cell__hd">当天里程</div>
                <div class=" weui-cell__hd">百公里油耗</div>
                <div class=" weui-cell__hd">当天累计油耗</div>
                <div class=" weui-cell__hd">当天累计里程</div>
            </div>
            <div id="datail-list"></div>
        </div>
    </div>
    <script>
    var backBTN = document.getElementById('back');
    backBTN.addEventListener('click', function() {
        window.history.back();
    });
    
    function initPage(){
        $.ajax({
            url: '/maintain/getConsumption',
            type: 'POST',
            data: {
                vhcle: localStorage.getItem('vhcle')
            },
            success: function (data) {
                if (data.state) {
                    var datas = data.data.list2;
                    datas.forEach(function(item) {
                        $('#datail-list').append(`
                        <div class="weui-cell item">
                            <div class=" weui-cell__hd">${item.date}</div>
                            <div class=" weui-cell__hd">${item.fuelConsumption}</div>
                            <div class=" weui-cell__hd">${item.mileage}</div>
                            <div class=" weui-cell__hd">${item.lp100km}</div>
                            <div class=" weui-cell__hd">${item.totalFuelConsumption}</div>
                            <div class=" weui-cell__hd">${item.totalMileage}</div>
                        </div>
                        `)
                    })
                } else {
                    TOAST.wran(data.errormsg, ' ', 1);
                }
            },
            error: function (err) {
                TOAST.wran('网络错误', ' ', 1)
            }
        })
    }
    initPage();
    </script>
</body>